Learn R Programming

LatticeKrig (version 9.3.0)

LKrig Internal: Internal functions for LatticeKrig package.

Description

Some internal functions for LKrig that estimate the coefficients of the basis functions and compute the likelihood.

Usage

LKrigMakewU(object, verbose = FALSE)
LKrigMakewX(object, verbose = FALSE)
LKrig.coef( GCholesky, wX, wU, wy, lambda,
collapseFixedEffect = FALSE,  verbose = FALSE)
LKrig.lnPlike( GCholesky, Q, quad.form, nObs, nReps, weights, LKinfo)
LKrig.traceA(GCholesky, wX, wU, lambda, weights, NtrA, iseed = NA)
LKrigUnrollZGrid( grid.list, ZGrid=NULL)
LKDefaultVarNames(A, tag)

Value

LKrig.coef

a list with components d.coef the coefficients of the spatial drift and for covariates (Z) and c.coef the basis function coefficients. The logical vector ind.drift from the LKrig object indicates with components of d.coef are associated with the polynomial spatial drift and which are other fixed spatial covariates.

LKrig.lnPlike

has the components:

lnProfileLike

the log likelihood profiled for lambda, alpha and a.wght

sigma2.MLE

the MLE of sigma2 given lambda, alpha and a.wght

shat.MLE

the MLE of tau given lambda, alpha and a.wght

quad.form

the quadratic form in the exponent of the multivariate normal likelihood

lnDetCov

the log determinant of the covariance matrix in the likelihood

LKrigDefaultFixedFunction

A matrix with dimension nrow(x) and columns of the number of polynomial terms and the number of columns of Z if given.

LKDefaultVarNames

The original column names ( e.g. the result of colnames(A) ) or some simple choices filled in.

Arguments

A

A matrix to add column names if not present.

collapseFixedEffect

If FALSE estimate fixed effects separately for each replicated data set.

grid.list

The grid for evaluating surface

GCholesky

SPAM cholesky decomposition of the "G" matrix.

iseed

Random seed used to generate the Monte Carlo samples. Keep the same to compare results with mKrig and also for multiple values of lambda.

lambda

The ratio of the nugget variance (tau squared) to the parameter controlling the marginal variance of the process (called sigma2 in fields).

LKinfo

The LKinfo object. See help(LKinfo)

NtrA

Number of Monte Carlo samples to estimate trace. Default is 20 in LKrig.

nObs

Number of observations.

nReps

Number of replicate fields.

object

The LKrig object.

Q

Precision matrix for coefficients.

quad.form

The part of the log likelihood that is a quadratic form. (This is typically found in LKrig.coef.)

tag

Text string to use as the column name. This will be followed 1, 2, ... for the names. E.g. X1 X2 X3. Default value will be the name of A.

verbose

If TRUE intermediate debugging information is printed.

weights

A vector that is proportional to the reciprocal variances of the errors. I.e. errors are assumed to be uncorrelated with variances tau^2/weights.

wU

Weighted U matrix the fixed part of the model.

wX

Weighted X matrix (in spam format) related to nonparametric (stochastic) part of model. Here weights refer to the sqrt(weights).

NOTE: predicted values are U%*%d.coef + X%*%c.coef

wy

Weighted observations.

ZGrid

A list or array with the covariates on the same grid as that specified by the grid.list argument.

Author

Doug Nychka

Details

The LatticeKrig article can be used as a reference for the matrix computations and the G matrix from those formulas figures prominently. The GCholesky object in these functions is the cholesky decomposition of this matrix. For compatibility with older version of this package this object may also be named as Mc ( Cholesky of the M matrix) but the user should not identify this M with that in the article. Ideally all coding using Mc should be changed to GCholesky.

createLKrigObject Based on the arguments passed into LKrig forms the prototype LKrig object. This object is added to as one computes additional steps in the LKrig function. The Names argument in the call is awkward device to pass the names of the original x, Z and U objects when substitued these names are used as the default prefixs for column names of these matrices.

LKrigMakewU and LKrigMakewX construct the weighted U and X matrices from what is passed. In the case of observations that are point locations wU is found the weights and using the fixedFunction and wX is found from the weights and the multi-resolution basis functions. Note that X and wX are assumed to be in spam sparse matrix format.

LKrig.coef and LKrig.lnPlike are two low level functions to find the basis function coefficients and to evaluate the likelihood. The coefficients (c.mKrig) are also found because they provide for shortcut formulas for the standard errors and MLE estimates. These coefficients are identical to the basis coefficients (c.coef) found for usual Kriging in the mKrig function. LKrig.lnPlike also finds the profile MLE of tau and sigma2 given a fixed value for lambda (and alpha and a.wght). See the source for LKrig and also MLE.LKrig to see how these functions are used.

LKrig.traceA finds an estimate of the effective degrees of freedom of the smoothing matrix based a simple Monte Carlo scheme. The smoothing matrix A is the matrix for fixed covariance parameters so that y.hat = A y, where y.hat are the predicted values at the data locations. trace(A) is the effective degrees of freedom. If e are iid N(0,1) then the expected value of t(e)% * % A % * % e is equal to the trace of A. This is the basis for estimating the trace and the standard error for this estimate is based on NtrA independent samples.

dfind2d is a fast FORTRAN subroutine to find nearest neighbors within a fixed distance and is called by Wendland.basis. The function dfind3d is currently not used but is intended for future use to determine chordal distance between points on a sphere or cylinder.

LKrigDefaultFixedFunction Is called to construct the fixed part of the spatial model. The default is a polynomial of degree (m-1).

LKDefaultVarNames A handyfunction to create some simple column names to a matrix if they are missing. This is used so that the tables of parameter estimates will have labels.

References

Nychka, D., Bandyopadhyay, S., Hammerling, D., Lindgren, F., & Sain, S. (2015). A multi-resolution Gaussian process model for the analysis of large spatial datasets.Journal of Computational and Graphical Statistics, 24(2), 579-599.

See Also

LKrig, LKrig.basis